package com.xh.demo.controller;

import com.xh.demo.commons.model.response.R;
import com.xh.demo.feign.OrderServiceFeign;
import com.xh.demo.model.request.OrderCreateRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wen
 * @apiNote TestController
 * @since 2021-12-10
 */
@Slf4j
@RestController
@RequestMapping("/fallback")
public class TestFeignFallbackController {

    @Autowired
    private OrderServiceFeign orderServiceFeign;

    @GetMapping("/order/detail/{id}")
    public R<String> orderDetail(@PathVariable("id") Long orderId) {
        return orderServiceFeign.detailV3(orderId);
    }

    @PostMapping("/order/{sku-id}")
    public R<String> create(@PathVariable("sku-id") Long skuId,
                            @RequestBody OrderCreateRequest request) {
        return orderServiceFeign.create(skuId, request);
    }


}
